<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>关键词列表</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="reserved.html">« 保留字列表</a></li>
      <li style="float: right;"><a href="reserved.classes.html">预定义类 »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="reserved.html">保留字列表</a></li>
    <li>关键词列表</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="reserved.keywords" class="sect1">
 <h2 class="title">关键词列表</h2>
  <p class="simpara">
   这些词语在 PHP
   中有着特殊的意义。它们中有些像是函数，有些像是常量，但是它们不是真的，它们只是语言结构的一部分。不能使用它们的任何一个作为常量、类名或函数名。但是它们可以被用作类的属性、常量以及类的方法名，或者接口名和
   traits 名，除了 <code class="literal">class</code> 不能被用作常量名。
  </p>

  <table class="doctable table">
   <caption><strong>PHP 关键词</strong></caption>
   
    <tbody class="tbody">
    <tr>
       <td>
        <span class="function"><a href="function.halt-compiler.html" class="function">__halt_compiler()</a></span>
       </td>
       <td>
        <a href="language.oop5.abstract.html" class="link">abstract</a>
       </td>
       <td>
        <a href="language.operators.logical.html" class="link">and</a>
       </td>
       <td>
        <span class="function"><a href="function.array.html" class="function">array()</a></span>
       </td>
       <td>
        <a href="control-structures.foreach.html" class="link">as</a>
       </td>
      </tr>

      <tr>
       <td>
        <a href="control-structures.break.html" class="link">break</a>
       </td>
       <td>
        <a href="language.types.callable.html" class="link">callable</a>
       </td>
       <td>
        <a href="control-structures.switch.html" class="link">case</a>
       </td>
       <td>
        <a href="language.exceptions.html" class="link">catch</a>
       </td>
       <td>
        <a href="language.oop5.basic.html#language.oop5.basic.class" class="link">class</a>
       </td>
      </tr>

      <tr>
       <td>
        <a href="language.oop5.cloning.html" class="link">clone</a>
       </td>
       <td>
        <a href="language.oop5.constants.html" class="link">const</a>
       </td>
       <td>
        <a href="control-structures.continue.html" class="link">continue</a>
       </td>
       <td>
        <a href="control-structures.declare.html" class="link">declare</a>
       </td>
       <td>
        <a href="control-structures.switch.html" class="link">default</a>
       </td>
      </tr>

      <tr>
       <td>
        <span class="function"><a href="function.die.html" class="function">die()</a></span>
       </td>
       <td>
        <a href="control-structures.do.while.html" class="link">do</a>
       </td>
       <td>
        <span class="function"><a href="function.echo.html" class="function">echo</a></span>
       </td>
       <td>
        <a href="control-structures.else.html" class="link">else</a>
       </td>
       <td>
        <a href="control-structures.elseif.html" class="link">elseif</a>
       </td>
      </tr>

      <tr>
       <td>
        <span class="function"><a href="function.empty.html" class="function">empty()</a></span>
       </td>
       <td>
        <a href="control-structures.declare.html" class="link">enddeclare</a>
       </td>
       <td>
        <a href="control-structures.alternative-syntax.html" class="link">endfor</a>
       </td>
       <td>
        <a href="control-structures.alternative-syntax.html" class="link">endforeach</a>
       </td>
       <td>
        <a href="control-structures.alternative-syntax.html" class="link">endif</a>
       </td>
      </tr>

      <tr>
       <td>
        <a href="control-structures.alternative-syntax.html" class="link">endswitch</a>
       </td>
       <td>
        <a href="control-structures.alternative-syntax.html" class="link">endwhile</a>
       </td>
       <td>
        <span class="function"><a href="function.eval.html" class="function">eval()</a></span>
       </td>
       <td>
        <span class="function"><a href="function.exit.html" class="function">exit()</a></span>
       </td>
       <td>
        <a href="language.oop5.basic.html#language.oop5.basic.extends" class="link">extends</a>
       </td>
      </tr>

      <tr>
       <td>
        <a href="language.oop5.final.html" class="link">final</a>
       </td>
       <td>
        <a href="language.exceptions.html" class="link">finally</a>
       </td>
       <td>
        <a href="functions.arrow.html" class="link">fn</a>（从 PHP 7.4 开始）
       </td>
       <td>
        <a href="control-structures.for.html" class="link">for</a>
       </td>
       <td>
        <a href="control-structures.foreach.html" class="link">foreach</a>
       </td>
      </tr>

      <tr>
       <td>
        <a href="functions.user-defined.html" class="link">function</a>
       </td>
       <td>
        <a href="language.variables.scope.html" class="link">global</a>
       </td>
       <td>
        <a href="control-structures.goto.html" class="link">goto</a>
       </td>
       <td>
        <a href="control-structures.if.html" class="link">if</a>
       </td>
       <td>
        <a href="language.oop5.interfaces.html" class="link">implements</a>
       </td>
      </tr>

      <tr>
       <td>
        <span class="function"><a href="function.include.html" class="function">include</a></span>
       </td>
       <td>
        <span class="function"><a href="function.include-once.html" class="function">include_once</a></span>
       </td>
       <td>
        <a href="language.operators.type.html" class="link">instanceof</a>
       </td>
       <td>
        <a href="language.oop5.traits.html#language.oop5.traits.conflict" class="link">insteadof</a>
       </td>
       <td>
        <a href="language.oop5.interfaces.html" class="link">interface</a>
       </td>
      </tr>

      <tr>
       <td>
        <span class="function"><a href="function.isset.html" class="function">isset()</a></span>
       </td>
       <td>
        <span class="function"><a href="function.list.html" class="function">list()</a></span>
       </td>
       <td>
        <a href="control-structures.match.html" class="link">match</a> （从 PHP 8.0 开始）
       </td>
       <td>
        <a href="language.namespaces.html" class="link">namespace</a>
       </td>
       <td>
        <a href="language.oop5.basic.html#language.oop5.basic.new" class="link">new</a>
       </td>
      </tr>

      <tr>
       <td>
        <a href="language.operators.logical.html" class="link">or</a>
       </td>
       <td>
        <span class="function"><a href="function.print.html" class="function">print</a></span>
       </td>
       <td>
        <a href="language.oop5.visibility.html" class="link">private</a>
       </td>
       <td>
        <a href="language.oop5.visibility.html" class="link">protected</a>
       </td>
       <td>
        <a href="language.oop5.visibility.html" class="link">public</a>
       </td>
      </tr>

      <tr>
       <td>
        <a href="language.oop5.properties.html#language.oop5.properties.readonly-properties" class="link">readonly</a>（自 PHP 8.1.0 起）*
       </td>
       <td>
        <span class="function"><a href="function.require.html" class="function">require</a></span>
       </td>
       <td>
        <span class="function"><a href="function.require-once.html" class="function">require_once</a></span>
       </td>
       <td>
        <span class="function"><a href="function.return.html" class="function">return</a></span>
       </td>
       <td>
        <a href="language.variables.scope.html" class="link">static</a>
       </td>
      </tr>

      <tr>
       <td>
        <a href="control-structures.switch.html" class="link">switch</a>
       </td>
       <td>
        <a href="language.exceptions.html" class="link">throw</a>
       </td>
       <td>
        <a href="language.oop5.traits.html" class="link">trait</a>
       </td>
       <td>
        <a href="language.exceptions.html" class="link">try</a>
       </td>
       <td>
        <span class="function"><a href="function.unset.html" class="function">unset()</a></span>
       </td>
      </tr>

      <tr>
       <td>
        <a href="language.namespaces.html" class="link">use</a>
       </td>
       <td>
        <a href="language.oop5.properties.html" class="link">var</a>
       </td>
       <td>
        <a href="control-structures.while.html" class="link">while</a>
       </td>
       <td>
        <a href="language.operators.logical.html" class="link">xor</a>
       </td>
       <td>
        <a href="language.generators.html" class="link">yield</a>
       </td>
      </tr>

      <tr>
       <td>
        <a href="language.generators.syntax.html#control-structures.yield.from" class="link">yield from</a>
       </td>
       <td class="empty">&nbsp;</td>
       <td class="empty">&nbsp;</td>
       <td class="empty">&nbsp;</td>
       <td class="empty">&nbsp;</td>
      </tr>

     </tbody>
    
   </table>


  <p class="simpara">
   * <code class="literal">readonly</code> 可用作函数名。
  </p>

  <table class="doctable table">
    <caption><strong>编译时常量</strong></caption>
    
     <tbody class="tbody">
      <tr>
       <td>
        <a href="language.constants.predefined.html" class="link">__CLASS__</a>
       </td>
       <td> 
        <a href="language.constants.predefined.html" class="link">__DIR__</a>
       </td>
       <td>
        <a href="language.constants.predefined.html" class="link">__FILE__</a>
       </td>
       <td>
        <a href="language.constants.predefined.html" class="link">__FUNCTION__</a>
       </td>
       <td>
        <a href="language.constants.predefined.html" class="link">__LINE__</a>
       </td>
       <td>
        <a href="language.constants.predefined.html" class="link">__METHOD__</a>
       </td>
      </tr>

      <tr>
       <td>
        <a href="language.namespaces.nsconstants.html" class="link">__NAMESPACE__</a>
       </td>
       <td>
        <a href="language.constants.predefined.html" class="link">__TRAIT__</a>
       </td>
       <td>
       </td>
       <td>
       </td>
       <td>
       </td>
       <td>
       </td>
      </tr>

     </tbody>
    
   </table>

  </div></div></div></body></html>